{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-header">
        <div class="layui-btn-group">
            <a href="{:url('store/rule/add')}" class="layui-btn ajax-iframe" data-width="80%">添加</a>
        </div>
    </div>
    
    <table id="tableList" lay-filter="tableList"></table>
    <!-- 表格操作列 -->
    <script type="text/html" id="tableTBTrack">
        <a href="{:url('store/rule/edit')}?id={{d.id}}" class="layui-btn layui-btn-sm ajax-iframe" data-width="80%">修改</a>
        <a href="{:url('store/rule/del')}?id={{d.id}}" class="layui-btn layui-btn-danger layui-btn-sm ajax-delete">删除</a>
    </script>
    <!-- 权限列 -->
    <script type="text/html" id="status">
        <input type="checkbox" name="status" lay-skin="switch" lay-filter="*" lay-text="正常|锁定" data-url="{:url('store/rule/edit')}?id={{d.id}}" {{d.status==1?'checked':''}}>
    </script>
    <!-- 权限列 -->
    <script type="text/html" id="sort_order">
        <input type="text" name="sort_order" value="{{d.sort_order}}" autocomplete="off" class="layui-input ajax-update" data-url="{:url('store/rule/edit')}?id={{d.id}}">
    </script>

</div>
{/block}

{block name="js"}
<script>
    layui.use(['layer', 'form', 'table', 'util', 'dropdown'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var util = layui.util;
        var admin = layui.admin;
        var dropdown = layui.dropdown;

        // 渲染回访表格
        var insTb = table.render({
            elem: '#tableList',
            url: "{:url('store/rule/index_json')}",
            page: true,
            cellMinWidth: 100,
            limit:'15',
            limits:[15,30,50,100,200],
            cols: [[
                {type:'numbers',title:'#'},
                {field: 'name', align: 'left', sort: true, title: '角色名称'},
                {field: 'description', align: 'left', sort: true, title: '角色描述'},                
                {align: 'center', sort: false, title: '排序',templet:'#sort_order'},
                {align: 'center', sort: false, title: '状态',templet:'#status'},
                {field: 'create_time', align: 'center', sort: true, title: '创建时间'},
                {align: 'center', toolbar: '#tableTBTrack', title: '操作', minWidth: 160}
            ]],
            parseData: function(res){ //res 即为原始返回的数据
                return {
                  "code": res.code, //解析接口状态
                  "msg": res.msg, //解析提示文本
                  "count": res.data.total, //解析数据长度
                  "data": res.data.data //解析数据列表
                };
            }
        });

    });

</script>
{/block}